package game;

import java.awt.Graphics2D;
import java.awt.Point;

class HudItem extends GameObject
{
	/**
	 * 
	 */
	public float hp, maxHp;
	
	public static boolean partindoDireita = false;
	
	private static final long serialVersionUID = 1L;

	
	
	public void addHP(float HP)
	{
		hp += HP;
	}
	
	public HudItem(Point position, Point size) 
	{
		super(position, size);
		hp = maxHp = 98;
	}
	@Override
	public void Update()
	{
		if(hp <= 0)
			hp = 0;
	}
	
	@Override
	public void draw(Graphics2D g2d) 
	{
		float p = hp/maxHp;
		
		g2d.drawImage(this.getImage(),
				(int)this.position.getX(),
				(int)this.position.getY(),
				(int)( this.position.getX() + (this.dimension.x * p)),
				(int)(this.getPosition().getY() + this.dimension.y),
				
				(int)(this.dimension.x - (this.dimension.x * p)),
				0,
				(int)(this.dimension.x - (this.dimension.x * p) + (this.dimension.x * (hp/maxHp))),
				this.dimension.y,
				null);
	}
}
